package com.example.foodchains;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;
public class MyDBClass extends SQLiteOpenHelper {

	// Database Version
    private static final int DATABASE_VERSION = 1;
 
    // Database Name
    private static final String DATABASE_NAME = "foodchainsDB";
 
    // Table Name
    private static final String TABLE_Player = "player";
    private static final String TABLE_Score = "score";
    private static final String TABLE_BG = "bg";
    private static final String TABLE_Picture = "picyure";
    
	public MyDBClass(Context context, String name, CursorFactory factory,
			int version) {
		super(context, name, factory, version);
		// TODO Auto-generated constructor stub
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		// TODO Auto-generated method stub
		
		// create table player
		db.execSQL("CREATE TABLE player " + TABLE_Player +
		          "(ID INTEGER PRIMARY KEY AUTOINCREMENT," +
		          " Name TEXT(100)," +
		          " Photo TEXT(100)," +
		          " Score INTEGER," +
		          " Level INTEGER));");
		Log.d("CREATE TABLE","Create Table player Successfully.");
		
		// create table score
		db.execSQL("CREATE TABLE score " + TABLE_Score +
				  "(ID INTEGER PRIMARY KEY AUTOINCREMENT," +
				  " FOREIGN KEY(Player_ID) REFERENCES Table_Player(ID));");
		Log.d("CREATE TABLE","Create Table Score Successfully.");
		
		// create table BG
		db.execSQL("CREATE TABLE bg " + TABLE_BG +
				  "(ID INTEGER PRIMARY KEY AUTOINCREMENT," +
				  " Name TEXT(100)," +
				  " TopLeftLat float," +
				  " TopLeftLong float," +
				  " BottomRightLat float," +
				  " BottomRightLong float));");
		Log.d("CREATE TABLE","Create Table BG Successfully.");
				
		
		// create table Picture
		db.execSQL("CREATE TABLE picture " + TABLE_Picture +
				  "(ID INTEGER PRIMARY KEY AUTOINCREMENT," +
				  " Name TEXT(100)," +
				  " Class float));");	
		
	    Log.d("CREATE TABLE","Create Table Picture Successfully.");
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		// TODO Auto-generated method stub
		
	}

}
